﻿// Copyright (C) 2012 Kim Jensen, TaskJunction.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaskJunctionLib.Model;

namespace TaskJunctionLib.Mapping.JSON
{
    public class UserMapper : JSONMapper<User>
    {
        public override void deserializeFromJSON(System.Json.JsonValue jsonObject, User obj)
        {
            obj.Id = jsonObject["id"].ReadAs<Int32>();
            obj.Email = jsonObject["email"].ReadAs<string>();
            obj.Mobile = jsonObject["mobile"].ReadAs<string>();
            obj.Phone = jsonObject["phone"].ReadAs<string>();
            obj.Name = jsonObject["name"].ReadAs<string>();
        }

        public override void serializeToJSON(System.Json.JsonValue jsonObject, User obj)
        {
            jsonObject["id"] = obj.Id;
            jsonObject["email"] = obj.Email;
            jsonObject["mobile"] = obj.Mobile;
            jsonObject["phone"] = obj.Phone;
            jsonObject["name"] = obj.Name;
        }

        protected override string JSONName()
        {
            return "user";
        }
    }
}
